<?php
require_once 'AMClassDefinition.php';
require_once 'MConfig.php';

class MXMLClassDefinition extends AMClassDefinition{

	/**
	 * Class Definition based on XML source
	 * Array structure:
	 *
	 * $arClass = array("name" => "ClassName", //name of the class
	 "path" => null, //path to the xml file or source
	 *
	 * @todo build XML structure 
	 * @param array $arDef
	 */
	 public function __construct(Array $arDef){
	 	$this->arDef = $arDef;
	 	$this->validate();
		MConfig::init($this->arDef['path']);
		$load = MConfig::$arCfg;
		
	 	$this->name = $this->arDef['name'];
	 	$this->args = $load['args'];
	 	$this->path = $this->arDef['path'];
	 	$this->require_once = $load['require_once'];
	 }

	 public function validate(){
	 	if(!array_key_exists('name', $this->arDef) && 
	 	   !array_key_exists('path', $this->arDef)) {
	 		throw new MException('ClassDefinition Array is not VALID!');
	 	}
	 	if(!MConfig::checkFile($this->arDef['path']))
	 		throw new MException('XML resource path is not correct!');
	 }
}
?>